Blowfish is a 8 byte block cipher so for shorter strings I'll need to pad
the byte array, and for longer strings I'll need to make it use cipher block
chaining:
(https://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29)
If you change #decryptString:with: to:
Blowfish class>>decryptString: aString with: aKey
|decryptedData |
decryptedData := (self new ecbDecrypt: aString asByteArray with: aKey
asByteArray �).
� � � � ^String fromByteArray: �decryptedData asByteArray .
Then this workspace code should work:
| enc encryptedString dkey decrString |
key:='mySecretKey'.
enc:=Blowfish encryptString:'12345678' with: key.
encryptedString := enc asByteArray asString.decrString:=Blowfish decryptString: encryptedString with: key.
Transcript show: ' encrypted: �', encryptedString; cr.
Transcript show: ' decrypted: �', decrString; cr.
But with the password 'test' it will always fail because I'm not yet padding
the byte array to a multiple of 8 bytes before encrypting it.
Thanks for your patience
Paul
--
View this message in context: http://forum.world.st/Pharo-dev-Recommendation-for-password-encryption-tp4698499p4698789.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.