"Invalid algorithm specified" when using AES with OFB cipher mode (VB.NET) -


i have use aes encryption ofb cipher mode , use vb.net 4.5 ,windows 8 , following code:

   public function doencryption(byval keyarray() byte, byval ivarray() byte, byval buffer string) byte()     dim encrypted() byte     using aes = aes.create()         a.mode = ciphermode.ofb          dim encryptor icryptotransform         encryptor = a.createencryptor(keyarray, ivarray)           ' create streams used encryption.          using msencrypt new memorystream()             using csencrypt new cryptostream(msencrypt, encryptor, cryptostreammode.write)                 using swencrypt new streamwriter(csencrypt)                      'write data stream.                     swencrypt.write(buffer)                 end using                 encrypted = msencrypt.toarray()             end using         end using     end using      return encrypted  end function 

i have error "invalid algorithm specified" @

  swencrypt.write(buffer) 

any suggestions?

yes works using bouncycastle @plutonix mentioned new code after install bouncycastle using nuget is:

imports system.security.cryptography imports system.io imports org.bouncycastle.crypto imports org.bouncycastle.security imports org.bouncycastle.crypto.parameters public class encryptionfunction public function doencryption(byval keyarray() byte, byval ivarray() byte, byval buffer byte()) byte()          dim ae new cipherkeygenerator()         ae.init(new keygenerationparameters(new securerandom(), 256))         dim aeskeyparam keyparameter = parameterutilities.createkeyparameter("aes", keyarray)         dim aesivkeyparam parameterswithiv = new parameterswithiv(aeskeyparam, ivarray)         dim cipher ibufferedcipher = cipherutilities.getcipher("aes/ofb/nopadding")         cipher.init(true, aesivkeyparam)         dim encrypted() byte = cipher.dofinal(buffer)           return encrypted      end function end class 

thank :)


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -