All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scalajs-ir-src.org.scalajs.ir.SHA1.scala Maven / Gradle / Ivy

There is a newer version: 3.7.2-RC1-bin-20250528-457a463-NIGHTLY
Show newest version
/*
 * Scala.js (https://www.scala-js.org/)
 *
 * Copyright EPFL.
 *
 * Licensed under Apache License 2.0
 * (https://www.apache.org/licenses/LICENSE-2.0).
 *
 * See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.
 */

package dotty.tools.sjs.ir

import scala.language.unsafeNulls
import java.security.MessageDigest

/** Wrapper around java.security.MessageDigest.getInstance("SHA-1") */
object SHA1 {
  final class DigestBuilder {
    private val digest = MessageDigest.getInstance("SHA-1")

    def update(b: Byte): Unit =
      digest.update(b)

    def update(b: Array[Byte]): Unit =
      digest.update(b)

    def update(b: Array[Byte], off: Int, len: Int): Unit =
      digest.update(b, off, len)

    def updateUTF8String(str: UTF8String): Unit =
      update(str.bytes)

    def finalizeDigest(): Array[Byte] =
      digest.digest()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy