[erlang-questions] Fwd: error in crypo module

Kenji Rikitake kenji.rikitake@REDACTED
Tue Jul 6 06:42:51 CEST 2010


Which version of Erlang are you using?
In R13B04 and before (inclusive), you need to do
crypto:start()
before using the crypto module functions.
In R14A, you don't have to.

Here it's like this:
-- begin --
Erlang R14A (erts-5.8) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8  (abort with ^G)
1> Key = <<16#01,16#23,16#45,16#67,16#89,16#ab,16#cd,16#ef>>.
<<1,35,69,103,137,171,205,239>>
2> IVec = <<16#12,16#34,16#56,16#78,16#90,16#ab,16#cd,16#ef>>.
<<18,52,86,120,144,171,205,239>>
3> P = "Now is the time for all ".
"Now is the time for all "
4> length(P).
24
5> C = crypto:des_cbc_encrypt(Key, IVec, P).
<<229,199,205,222,135,43,242,124,67,233,52,0,140,56,156,
  15,104,55,136,73,154,124,5,246>>
6> P2 = crypto:des_cbc_decrypt(Key, IVec, C).
<<"Now is the time for all ">>

10> P3 = erlang:binary_to_list(P2).
"Now is the time for all "
11> P3 =:= P.
true
-- end --

Kenji Rikitake

In the message <AANLkTik19pGb8lhoGFD4fHJsX78bz6OnjFrU5Ko4XQn-@REDACTED>
dated Mon, Jul 05, 2010 at 11:53:01PM -0400,
johnpaul ci <ci.johnpaul87@REDACTED> writes:

> 3>Key = <<16#01,16#23,16#45,16#67,16#89,16#ab,16#cd,16#ef>>.
> <<1,35,69,103,137,171,205,239>>
> 4> IVec = <<16#12,16#34,16#56,16#78,16#90,16#ab,16#cd,16#ef>>.
> <<18,52,86,120,144,171,205,239>>
> 5> P = "Now is the time for all ".
> "Now is the time for all "
> 6> C = crypto:des_cbc_encrypt(Key, IVec, P).
> ** exception error: bad argument
>      in function  port_control/3
>         called as port_control(crypto_drv02,13,
>                                [<<1,35,69,103,137,171,205,239>>,
>                                 <<18,52,86,120,144,171,205,239>>,
>                                 "Now is the time for all "])
>      in call from crypto:control/2


More information about the erlang-questions mailing list