CardEncryptor

public enum CardEncryptor

An object that provides static methods for encrypting card information and retrieving public keys from the server.

Card Encryption

  • Encrypts a card.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidCard when trying to encrypt a card with card number, securityCode, expiryMonth, and expiryYear, all of them are nil.

    Declaration

    Swift

    public static func encrypt(card: Card, with publicKey: String) throws -> EncryptedCard

    Parameters

    card

    Card containing the data to be encrypted.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted card containing the individually encrypted fields.

  • Encrypts card number.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidNumber when trying to encrypt an empty or invalid card number

    Declaration

    Swift

    public static func encrypt(number: String, with publicKey: String) throws -> String

    Parameters

    number

    The card number

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted token containing card number data.

  • Encrypts security code.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidSecureCode when trying to encrypt an empty or invalid securityCode.

    Declaration

    Swift

    public static func encrypt(securityCode: String, with publicKey: String) throws -> String

    Parameters

    securityCode

    The card’s security code.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted token containing security code data.

  • Encrypts enspiration month.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidExpiryMonth when trying to encrypt an empty or invalid expiryMonth.

    Declaration

    Swift

    public static func encrypt(expirationMonth: String, with publicKey: String) throws -> String

    Parameters

    expiryMonth

    The expiration month.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted token enspiration month data.

  • Encrypts enspiration year.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidExpiryYear when trying to encrypt an empty or invalid expiryYear.

    Declaration

    Swift

    public static func encrypt(expirationYear: String, with publicKey: String) throws -> String

    Parameters

    expiryMonth

    The expiration year.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted token containing enspiration year data.

  • Encrypt BIN.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidBin when trying to encrypt an empty or invalid BIN.

    Declaration

    Swift

    public static func encrypt(bin: String, with publicKey: String) throws -> String

    Parameters

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    bin

    BIN( Bank Identification number) is the first 6 to 12 digits of PAN.

    Return Value

    An encrypted token containing BIN data.

  • Encrypts password.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.emptyValue when trying to encrypt an empty value.

    Declaration

    Swift

    public static func encrypt(password: String, with publicKey: String) throws -> String

    Parameters

    password

    The non-empty value.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted token containing enspiration year data.

  • Encrypts a card as a token.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidEncryptionArguments when trying to encrypt a card with card number, securityCode, expiryMonth, and expiryYear, all of them are nil.

    Declaration

    Swift

    public static func encryptToken(from card: Card, with publicKey: String) throws -> String

    Parameters

    card

    Card containing the data to be encrypted.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    A string token containig encrypted card data.

Error

  • Describes the error that can occur during card encryption and public key fetching.

    See more

    Declaration

    Swift

    public enum Error : Swift.Error, LocalizedError