FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
crypto/des: add an example to demonstrate EDE2 operation.

EDE2 is a rare DES mode that can be implemented with crypto/des, but
it's somewhat non-obvious so this CL adds an example of doing so.

Fixes issue 3537.

Please review this at http://codereview.appspot.com/6721056/

Affected files:
M src/pkg/crypto/des/des_test.go


Index: src/pkg/crypto/des/des_test.go
===================================================================
--- a/src/pkg/crypto/des/des_test.go
+++ b/src/pkg/crypto/des/des_test.go
@@ -1503,3 +1503,21 @@
}
}
}
+
+func ExampleNewTripleDESCipher() {
+ // NewTripleDESCipher can also be used when EDE2 is required by
+ // duplicating the first 8 bytes of the 16-byte key.
+ ede2Key := []byte("example key 1234")
+
+ var tripleDESKey []byte
+ tripleDESKey = append(tripleDESKey, ede2Key[:16])
+ tripleDESKey = append(tripleDESKey, ede2Key[:8])
+
+ c, err := NewTripleDESCipher(tripleDESKey)
+ if err != nil {
+ panic(err)
+ }
+
+ // See crypto/cipher for how to use a cipher.Block for encryption and
+ // decryption.
+}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 17, '12 at 11:37p
activeOct 17, '12 at 11:37p
posts1
users1
websitegolang.org

1 user in discussion

Agl: 1 post

People

Translate

site design / logo © 2022 Grokbase