anchor.diff:              Error
       end.
   
  +%% @doc Generate an access key for a user
  +-spec generate_key(binary()) -> string().
  +generate_key(UserName) ->
  +    Ctx = crypto:hmac_init(sha, UserName),
  +    Ctx1 = crypto:hmac_update(Ctx, druuid:v4()),
  +    Key = crypto:hmac_final_n(Ctx1, 15),
  +    string:to_upper(base64:encode_to_string(Key)).
  +
  +%% @doc Generate a secret access token for a user
  +-spec generate_secret(binary(), string()) -> string().
  +generate_secret(UserName, Key) ->
  +    Bytes = 14,
  +    Ctx = crypto:hmac_init(sha, UserName),
  +    Ctx1 = crypto:hmac_update(Ctx, list_to_binary(Key)),
  +    SecretPart1 = crypto:hmac_final_n(Ctx1, Bytes),
  +    Ctx2 = crypto:hmac_init(sha, UserName),
  +    Ctx3 = crypto:hmac_update(Ctx2, druuid:v4()),
  +    SecretPart2 = crypto:hmac_final_n(Ctx3, Bytes),
  +    base64:encode_to_string(
  +      iolist_to_binary(<< SecretPart1:Bytes/binary,
  +                          SecretPart2:Bytes/binary >>)).
  +
   %% @doc Save information about a MOSS user
   -spec save_user(moss_user(), pid()) -> ok.
   save_user(User, RiakPid) ->
  
positive.code:     %% @TODO Error handling
      ok = riakc_pb_socket:put(RiakPid, UserObj),
      ok.
  
negative.code:          put_object/4,
           riak_connection/0,
           riak_connection/2,
           to_bucket_name/2]).
  
  -include("riak_moss.hrl").
  
  