Files
LingChair/client/static/crypto-es@3.1.0/format-hex.mjs
2025-09-06 23:28:50 +08:00

22 lines
571 B
JavaScript

import { Hex } from "./core.mjs";
import { CipherParams } from "./cipher-core.mjs";
//#region src/format-hex.ts
/**
* Hex formatter for cipher params.
* Converts cipher params to/from hexadecimal strings.
*/
const HexFormatter = {
stringify(cipherParams) {
if (!cipherParams.ciphertext) throw new Error("Ciphertext is required");
return cipherParams.ciphertext.toString(Hex);
},
parse(input) {
const ciphertext = Hex.parse(input);
return CipherParams.create({ ciphertext });
}
};
//#endregion
export { HexFormatter };
//# sourceMappingURL=format-hex.mjs.map