• Encrypt a String

    Type Parameters

    • Options extends {
          algorithm?: string;
          output?: "buffer" | BufferEncoding;
      }

    Parameters

    • input: string
    • key: BinaryLike
    • Optional options: Options

    Returns Options["output"] extends "buffer"
        ? Buffer
        : string

    Example

    import { string } from "@rjweb/utils"

    string.encrypt('Hello', 'secret', { algorithm: 'aes-256-cbc', output: 'hex' }) // df4d0fe46e0210d4ef46368a6c3d56bb

    Since

    1.0.0

    Supports

    nodejs