All files / output cl_abap_message_digest.clas.mjs

27.69% Statements 18/65
100% Branches 2/2
6.66% Functions 1/15
27.69% Lines 18/65

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 651x 1x 1x 1x 1x 1x 1x 1x 1x 1x             1x       1x     1x                               1x     1x                                       1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_abap_message_digest.clas.abap
class cl_abap_message_digest {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_ABAP_MESSAGE_DIGEST';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"CALCULATE_HASH_FOR_RAW": {"visibility": "U", "parameters": {"IF_ALGORITHM": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IF_DATA": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "EF_HASHXSTRING": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}}},
  "CALCULATE_HASH_FOR_CHAR": {"visibility": "U", "parameters": {"IF_ALGORITHM": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IF_DATA": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "EF_HASHXSTRING": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "EF_HASHSTRING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "EF_HASHB64STRING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async calculate_hash_for_raw(INPUT) {
    return cl_abap_message_digest.calculate_hash_for_raw(INPUT);
  }
  static async calculate_hash_for_raw(INPUT) {
    let if_algorithm = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.if_algorithm) {if_algorithm.set(INPUT.if_algorithm);}
    if (INPUT === undefined || INPUT.if_algorithm === undefined) {if_algorithm = abap.CharacterFactory.get(4, 'SHA1');}
    let if_data = INPUT?.if_data;
    if (if_data?.getQualifiedName === undefined || if_data.getQualifiedName() !== "XSTRING") { if_data = undefined; }
    if (if_data === undefined) { if_data = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.if_data); }
    let ef_hashxstring = INPUT?.ef_hashxstring || new abap.types.XString({qualifiedName: "XSTRING"});
    let lv_algorithm = new abap.types.String({qualifiedName: "STRING"});
    lv_algorithm.set(abap.builtin.to_lower({val: if_algorithm}));
    abap.statements.assert(abap.compare.eq(lv_algorithm, abap.CharacterFactory.get(4, 'sha1')) || abap.compare.eq(lv_algorithm, abap.CharacterFactory.get(3, 'md5')) || abap.compare.eq(lv_algorithm, abap.CharacterFactory.get(6, 'sha256')));
    const crypto = await import("crypto");
    var shasum = crypto.createHash(lv_algorithm.get());
    shasum.update(if_data.get(), "hex");
    ef_hashxstring.set(shasum.digest("hex").toUpperCase());
  }
  async calculate_hash_for_char(INPUT) {
    return cl_abap_message_digest.calculate_hash_for_char(INPUT);
  }
  static async calculate_hash_for_char(INPUT) {
    let if_algorithm = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.if_algorithm) {if_algorithm.set(INPUT.if_algorithm);}
    if (INPUT === undefined || INPUT.if_algorithm === undefined) {if_algorithm = abap.CharacterFactory.get(4, 'SHA1');}
    let if_data = INPUT?.if_data;
    if (if_data?.getQualifiedName === undefined || if_data.getQualifiedName() !== "STRING") { if_data = undefined; }
    if (if_data === undefined) { if_data = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.if_data); }
    let ef_hashxstring = INPUT?.ef_hashxstring || new abap.types.XString({qualifiedName: "XSTRING"});
    let ef_hashstring = INPUT?.ef_hashstring || new abap.types.String({qualifiedName: "STRING"});
    let ef_hashb64string = INPUT?.ef_hashb64string || new abap.types.String({qualifiedName: "STRING"});
    let lv_algorithm = new abap.types.String({qualifiedName: "STRING"});
    lv_algorithm.set(abap.builtin.to_lower({val: if_algorithm}));
    abap.statements.assert(abap.compare.eq(lv_algorithm, abap.CharacterFactory.get(4, 'sha1')) || abap.compare.eq(lv_algorithm, abap.CharacterFactory.get(3, 'md5')) || abap.compare.eq(lv_algorithm, abap.CharacterFactory.get(6, 'sha256')));
    const crypto = await import("crypto");
    var shasum = crypto.createHash(lv_algorithm.get());
    shasum.update(if_data.get());
    ef_hashxstring.set(shasum.digest("hex").toUpperCase());
    ef_hashb64string.set(Buffer.from(ef_hashxstring.get(), "hex").toString("base64"));
    ef_hashstring.set(ef_hashxstring);
  }
}
abap.Classes['CL_ABAP_MESSAGE_DIGEST'] = cl_abap_message_digest;
export {cl_abap_message_digest};