Back

unpad (clj)

(source)

function

(unpad input) (unpad input alg)
Remove padding from given byte array and fill the unpadded bytes with 0

Examples

funcool/buddy-core
(ns buddy.core.padding-tests
  (:require [clojure.test :refer :all]
            [buddy.core.codecs :as codecs]
            [buddy.core.bytes :as bytes]
            [buddy.core.padding :as padding]))

    (let [result (padding/unpad data :pkcs7)]
      (is (bytes/equals? result (bytes/slice data 0 6))))))

    (let [result (padding/unpad data :tbc)]
      (is (bytes/equals? result (bytes/slice data 0 6))))))

    (let [result (padding/unpad data :zerobyte)]
      (is (bytes/equals? result (bytes/slice data 0 6))))))