18F/identity-idp

View on GitHub
app/services/encryption/encodable.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module Encryption
  module Encodable
    extend ActiveSupport::Concern

    private

    def valid_base64_encoding?(text)
      Base64.strict_decode64(text)
    rescue StandardError
      false
    end

    def encode(text)
      Base64.strict_encode64(text)
    end

    def decode(text)
      Base64.strict_decode64(text)
    end
  end
end