1. 程式人生 > >4.3 使用元組-密碼加密

4.3 使用元組-密碼加密

test() ->
    title(),
    Password = "DECLARATIVE",
    entries([{"3451",Password,lisa},
             {"1234",Password,carwash},
             {"4321",Password,bigbank},
             {"7568",Password,doorcode1},
             {"8832",Password,doorcode2},
             {"4278",Password,cashcard},
             {"4278",Password,chequecard}]).

title() ->
    io:format("a b c d e f g h i j k l m \
               n o p q r s t u v w x y z~n",[]).

entries(List) ->
    {_,_,Seed} = time(),
    entries(List, Seed).

entries([], _) -> true;

entries([{Pin,Password,Title}|T], Seed) ->
    Code = encode(Pin, Password),
    NewSeed = print_code(tuple_to_list(Code), Seed),
    io:format(" ~w~n",[Title]),
    entries(T, NewSeed).