Skip to content

Attempting to decrypt a nonsensical string causes an error #2

@suprafly

Description

@suprafly

Example:
Cipher.decrypt("ddd")

Error
** (MatchError) no match of right hand side value: :error
lib/cipher.ex:36: Cipher.decrypt/1

on line 36 of lib/cipher.ex:
{:ok, decoded} = crypted |> URI.decode_www_form |> Base.decode64

Why does this matter?
Because there may be cases where you are attempting to decrypt something, say an encrypted token coming over an api endpoint, and it may have been injected by a hacker. Should fail gracefully with a sensible reason why.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions