Class Utilities

유틸리티

이 서비스는 문자열 인코딩/디코딩, 날짜 형식 지정, JSON 조작, 기타 작업을 위한 유틸리티를 제공합니다.

속성

속성유형설명
CharsetCharset
DigestAlgorithmDigestAlgorithm
MacAlgorithmMacAlgorithm
RsaAlgorithmRsaAlgorithm

방법

메서드반환 유형간략한 설명
base64Decode(encoded)Byte[]base-64로 인코딩된 문자열을 UTF-8 바이트 배열로 디코딩합니다.
base64Decode(encoded, charset)Byte[]base-64로 인코딩된 문자열을 특정 문자 집합의 바이트 배열로 디코딩합니다.
base64DecodeWebSafe(encoded)Byte[]base-64 웹 안전 인코딩 문자열을 UTF-8 바이트 배열로 디코딩합니다.
base64DecodeWebSafe(encoded, charset)Byte[]base-64 웹 안전 인코딩 문자열을 특정 문자 집합의 바이트 배열로 디코딩합니다.
base64Encode(data)String지정된 바이트 배열에서 base-64로 인코딩된 문자열을 생성합니다.
base64Encode(data)String지정된 문자열에서 base-64로 인코딩된 문자열을 생성합니다.
base64Encode(data, charset)String특정 문자 집합의 지정된 문자열에서 base-64로 인코딩된 문자열을 생성합니다.
base64EncodeWebSafe(data)String지정된 바이트 배열에서 base-64 웹 안전 인코딩 문자열을 생성합니다.
base64EncodeWebSafe(data)String지정된 문자열에서 base-64 웹 안전 인코딩 문자열을 생성합니다.
base64EncodeWebSafe(data, charset)String특정 문자 집합의 지정된 문자열에서 base-64 웹 안전 인코딩 문자열을 생성합니다.
computeDigest(algorithm, value)Byte[]지정된 Byte[] 값에 지정된 알고리즘을 사용하여 다이제스트를 계산합니다.
computeDigest(algorithm, value)Byte[]지정된 String 값에 지정된 알고리즘을 사용하여 다이제스트를 계산합니다.
computeDigest(algorithm, value, charset)Byte[]지정된 문자 집합으로 지정된 String 값에 지정된 알고리즘을 사용하여 다이제스트를 계산합니다.
computeHmacSha256Signature(value, key)Byte[]지정된 키로 HMAC-SHA256을 사용하여 제공된 값에 서명합니다.
computeHmacSha256Signature(value, key)Byte[]지정된 키로 HMAC-SHA256을 사용하여 제공된 값에 서명합니다.
computeHmacSha256Signature(value, key, charset)Byte[]지정된 키 및 문자 집합과 함께 HMAC-SHA256을 사용하여 제공된 값에 서명합니다.
computeHmacSignature(algorithm, value, key)Byte[]지정된 키와 값에 지정된 알고리즘을 사용하여 메시지 인증 코드를 계산합니다.
computeHmacSignature(algorithm, value, key)Byte[]지정된 키와 값에 지정된 알고리즘을 사용하여 메시지 인증 코드를 계산합니다.
computeHmacSignature(algorithm, value, key, charset)Byte[]지정된 키와 값에 지정된 알고리즘을 사용하여 메시지 인증 코드를 계산합니다.
computeRsaSha1Signature(value, key)Byte[]지정된 키로 RSA-SHA1을 사용하여 제공된 값에 서명합니다.
computeRsaSha1Signature(value, key, charset)Byte[]지정된 키와 문자 집합으로 RSA-SHA1을 사용하여 제공된 값에 서명합니다.
computeRsaSha256Signature(value, key)Byte[]지정된 키로 RSA-SHA256을 사용하여 제공된 값에 서명합니다.
computeRsaSha256Signature(value, key, charset)Byte[]지정된 키로 RSA-SHA256을 사용하여 제공된 값에 서명합니다.
computeRsaSignature(algorithm, value, key)Byte[]지정된 키로 지정된 RSA 알고리즘을 사용하여 제공된 값에 서명합니다.
computeRsaSignature(algorithm, value, key, charset)Byte[]지정된 키 및 문자 집합으로 지정된 RSA 알고리즘을 사용하여 제공된 값에 서명합니다.
formatDate(date, timeZone, format)String자바 SE SimpleDateFormat 클래스에 설명된 사양에 따라 날짜 형식을 지정합니다.
formatString(template, args)String'%' 스타일 형식 문자열을 사용하여 sprintf와 유사한 문자열 형식을 실행합니다.
getUuid()StringUUID를 문자열로 가져옵니다 (java.util.UUID.randomUUID() 메서드를 사용하는 것과 동일).
gzip(blob)Blobgzip는 제공된 Blob 데이터를 압축하여 새 Blob 객체에 반환합니다.
gzip(blob, name)Blobgzip는 제공된 Blob 데이터를 압축하여 새 Blob 객체에 반환합니다.
newBlob(data)Blob바이트 배열에서 새 Blob 객체를 만듭니다.
newBlob(data, contentType)Blob바이트 배열 및 콘텐츠 유형에서 새 Blob 객체를 만듭니다.
newBlob(data, contentType, name)Blob바이트 배열, 콘텐츠 유형, 이름에서 새 Blob 객체를 만듭니다.
newBlob(data)Blob문자열에서 새 Blob 객체를 만듭니다.
newBlob(data, contentType)Blob문자열과 콘텐츠 유형에서 새 Blob 객체를 만듭니다.
newBlob(data, contentType, name)Blob문자열, 콘텐츠 유형, 이름에서 새 Blob 객체를 만듭니다.
parseCsv(csv)String[][]CSV 문자열의 표 형식 2D 배열 표현을 반환합니다.
parseCsv(csv, delimiter)String[][]커스텀 구분자를 사용하여 CSV 문자열의 표 형식 2D 배열 표현을 반환합니다.
parseDate(date, timeZone, format)DateJava Standard Edition SimpleDateFormat 클래스에 설명된 사양에 따라 제공된 문자열 날짜를 파싱합니다.
sleep(milliseconds)void지정된 밀리초 동안 절전 모드로 전환됩니다.
ungzip(blob)BlobBlob 객체의 압축을 풀고 압축되지 않은 데이터가 포함된 Blob를 반환합니다.
unzip(blob)Blob[]zip 파일을 나타내는 Blob을 가져와 구성요소 파일을 반환합니다.
zip(blobs)Blob전달된 Blob의 데이터를 포함하는 ZIP 파일인 새 Blob 객체를 만듭니다.
zip(blobs, name)Blob전달된 Blob의 데이터를 포함하는 ZIP 파일인 새 Blob 객체를 만듭니다.

자세한 문서

base64Decode(encoded)

base-64로 인코딩된 문자열을 UTF-8 바이트 배열로 디코딩합니다.

// This is the base64 encoded form of "Google グループ"
var base64data = "R29vZ2xlIOOCsOODq+ODvOODlw==";

// This logs:
//     [71, 111, 111, 103, 108, 101, 32, -29, -126, -80,
//      -29, -125, -85, -29, -125, -68, -29, -125, -105]
var decoded = Utilities.base64Decode(base64data);
Logger.log(decoded);

// If we want a String instead of a byte array:
// This logs the original "Google グループ"
Logger.log(Utilities.newBlob(decoded).getDataAsString());

매개변수

이름유형설명
encodedString디코딩할 데이터의 바이트 배열입니다.

리턴

Byte[] - base-64로 인코딩된 인수로 표현되는 원시 데이터이며 바이트 배열입니다.


base64Decode(encoded, charset)

base-64로 인코딩된 문자열을 특정 문자 집합의 바이트 배열로 디코딩합니다.

// This is the base64 encoded form of "Google グループ"
var base64data = "R29vZ2xlIOOCsOODq+ODvOODlw==";

var decoded = Utilities.base64Decode(base64data, Utilities.Charset.UTF_8);

// This logs:
//     [71, 111, 111, 103, 108, 101, 32, -29, -126, -80,
//      -29, -125, -85, -29, -125, -68, -29, -125, -105]
Logger.log(decoded);

// If we want a String instead of a byte array:
// This logs the original "Google グループ"
Logger.log(Utilities.newBlob(decoded).getDataAsString());

매개변수

이름유형설명
encodedString디코딩할 데이터 문자열입니다.
charsetCharset입력의 문자 집합을 지정하는 Charset입니다.

리턴

Byte[] - base-64로 인코딩된 인수로 표현되는 원시 데이터이며 바이트 배열입니다.


base64DecodeWebSafe(encoded)

base-64 웹 안전 인코딩 문자열을 UTF-8 바이트 배열로 디코딩합니다.

// This is the base64 web-safe encoded form of "Google グループ"
var base64data = "R29vZ2xlIOOCsOODq-ODvOODlw==";

var decoded = Utilities.base64DecodeWebSafe(base64data);

// This logs:
//     [71, 111, 111, 103, 108, 101, 32, -29, -126, -80,
//      -29, -125, -85, -29, -125, -68, -29, -125, -105]
Logger.log(decoded);

// If we want a String instead of a byte array:
// This logs the original "Google グループ"
Logger.log(Utilities.newBlob(decoded).getDataAsString());

매개변수

이름유형설명
encodedString디코딩할 웹에 적합한 데이터의 바이트 배열입니다.

리턴

Byte[] - base-64 웹에 적합한 인코딩 인수로 표현되는 원시 데이터이며 바이트 배열입니다.


base64DecodeWebSafe(encoded, charset)

base-64 웹 안전 인코딩 문자열을 특정 문자 집합의 바이트 배열로 디코딩합니다.

// This is the base64 web-safe encoded form of "Google グループ"
var base64data = "R29vZ2xlIOOCsOODq-ODvOODlw==";

var decoded = Utilities.base64DecodeWebSafe(base64data, Utilities.Charset.UTF_8);

// This logs:
//     [71, 111, 111, 103, 108, 101, 32, -29, -126, -80,
//      -29, -125, -85, -29, -125, -68, -29, -125, -105]
Logger.log(decoded);

// If we want a String instead of a byte array:
// This logs the original "Google グループ"
Logger.log(Utilities.newBlob(decoded).getDataAsString());

매개변수

이름유형설명
encodedString디코딩할 웹에 적합한 데이터 문자열입니다.
charsetCharset입력의 문자 집합을 지정하는 Charset입니다.

리턴

Byte[] - base-64 웹에 적합한 인코딩 인수로 표현되는 원시 데이터이며 바이트 배열입니다.


base64Encode(data)

지정된 바이트 배열에서 base-64로 인코딩된 문자열을 생성합니다. Base64는 바이너리 데이터를 허용하지 않는 다양한 도구에서 허용되는 일반적인 인코딩입니다. Base64는 일반적으로 이메일, HTTP 또는 XML 문서와 같은 인터넷 프로토콜에서 사용됩니다.

// Instantiates a blob here for clarity
var blob = Utilities.newBlob("A string here");

// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log.
var encoded = Utilities.base64Encode(blob.getBytes());
Logger.log(encoded);

매개변수

이름유형설명
dataByte[]인코딩할 데이터의 byte[] 입니다.

리턴

String - 데이터에 전달된 데이터의 base64로 인코딩된 표현입니다.


base64Encode(data)

지정된 문자열에서 base-64로 인코딩된 문자열을 생성합니다. Base64는 바이너리 데이터를 허용하지 않는 다양한 도구에서 허용하는 공통 인코딩입니다. Base64는 일반적으로 이메일, HTTP 또는 XML 문서와 같은 인터넷 프로토콜에서 사용됩니다.

// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log.
var encoded = Utilities.base64Encode("A string here");
Logger.log(encoded);

매개변수

이름유형설명
dataString인코딩할 문자열입니다.

리턴

String - 입력 문자열의 base64로 인코딩된 표현입니다.


base64Encode(data, charset)

특정 문자 집합의 지정된 문자열에서 base-64로 인코딩된 문자열을 생성합니다. 문자 집합은 문자를 인코딩할 수 있도록 인코딩하는 방법입니다. 이는 일반적으로 바이너리 형식으로 수행되며 일반적으로 특정 데이터 전송 프로토콜과 호환되지 않을 수 있습니다. 데이터가 호환되도록 하기 위해 일반적으로 base64로 인코딩됩니다. base64는 바이너리 데이터를 허용할 수 없는 다양한 도구에서 허용되는 공통 인코딩입니다. Base64는 일반적으로 이메일, HTTP 또는 XML 문서와 같은 인터넷 프로토콜에서 사용됩니다.

// "Google Groups" in Katakana (Japanese)
var input = "Google グループ";

// Writes "R29vZ2xlIOOCsOODq+ODvOODlw==" to the log
var encoded = Utilities.base64Encode(input, Utilities.Charset.UTF_8);
Logger.log(encoded);

매개변수

이름유형설명
dataString인코딩할 데이터 문자열입니다.
charsetCharset입력의 문자 집합을 지정하는 Charset입니다.

리턴

String - 지정된 Charset를 사용한 입력 문자열의 base64로 인코딩된 표현입니다.


base64EncodeWebSafe(data)

지정된 바이트 배열에서 base-64 웹 안전 인코딩 문자열을 생성합니다. Base64는 바이너리 데이터를 허용하지 않는 다양한 도구에서 허용하는 일반적인 인코딩입니다. Base64 웹 안전은 일반적으로 이메일, HTTP 또는 XML 문서와 같은 인터넷 프로토콜에서 사용됩니다.

// Instantiates a blob here for clarity
var blob = Utilities.newBlob("A string here");

// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log.
var encoded = Utilities.base64EncodeWebSafe(blob.getBytes());
Logger.log(encoded);

매개변수

이름유형설명
dataByte[]인코딩할 데이터의 바이트 배열입니다.

리턴

String - 데이터에서 전달된 base-64 웹 안전 인코딩 표현입니다.


base64EncodeWebSafe(data)

지정된 문자열에서 base-64 웹 안전 인코딩 문자열을 생성합니다. Base64는 바이너리 데이터를 허용하지 않는 다양한 도구에서 허용되는 일반적인 인코딩입니다. Base64 웹 안전은 일반적으로 이메일, HTTP 또는 XML 문서와 같은 인터넷 프로토콜에서 사용됩니다.

// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log.
var encoded = Utilities.base64EncodeWebSafe("A string here");
Logger.log(encoded);

매개변수

이름유형설명
dataString인코딩할 문자열입니다.

리턴

String - 입력 문자열의 base-64 웹 안전 인코딩 표현입니다.


base64EncodeWebSafe(data, charset)

특정 문자 집합의 지정된 문자열에서 base-64 웹 안전 인코딩 문자열을 생성합니다. 문자 집합은 문자를 인코딩할 수 있도록 인코딩하는 방법입니다. 이는 일반적으로 바이너리 형식으로 수행되며 일반적으로 특정 데이터 전송 프로토콜과 호환되지 않을 수 있습니다. 데이터가 호환되도록 하기 위해 일반적으로 base64로 인코딩됩니다. base64는 바이너리 데이터를 허용할 수 없는 다양한 도구에서 허용하는 공통 인코딩입니다. Base64 웹 안전은 일반적으로 이메일, HTTP 또는 XML 문서와 같은 인터넷 프로토콜에서 사용됩니다.

// "Google Groups" in Katakana (Japanese)
var input = "Google グループ";

// Writes "R29vZ2xlIOOCsOODq-ODvOODlw==" to the log
var encoded = Utilities.base64EncodeWebSafe(input, Utilities.Charset.UTF_8);
Logger.log(encoded);

매개변수

이름유형설명
dataString인코딩할 데이터 문자열입니다.
charsetCharset입력의 문자 집합을 지정하는 Charset입니다.

리턴

String - 지정된 Charset를 사용한 입력 문자열의 base-64 웹 안전 인코딩 표현입니다.


computeDigest(algorithm, value)

지정된 Byte[] 값에 지정된 알고리즘을 사용하여 다이제스트를 계산합니다.

var input = Utilities.base64Decode("aW5wdXQgdG8gaGFzaA0K") // == base64encode("input to hash")
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, input);
Logger.log(digest);

매개변수

이름유형설명
algorithmDigestAlgorithm사용할 DigestAlgorithm.
valueByte[]다이제스트를 계산할 입력 문자열 값입니다.

리턴

Byte[] - 출력 다이제스트를 나타내는 byte[] 입니다.


computeDigest(algorithm, value)

지정된 String 값에 지정된 알고리즘을 사용하여 다이제스트를 계산합니다.

var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, "input to hash");
Logger.log(digest);

매개변수

이름유형설명
algorithmDigestAlgorithm사용할 DigestAlgorithm.
valueString다이제스트를 계산할 입력 문자열 값입니다.

리턴

Byte[] - 출력 다이제스트를 나타내는 byte[] 입니다.


computeDigest(algorithm, value, charset)

지정된 문자 집합으로 지정된 String 값에 지정된 알고리즘을 사용하여 다이제스트를 계산합니다.

var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5,
                                     "input to hash",
                                     Utilities.Charset.US_ASCII);
Logger.log(digest);

매개변수

이름유형설명
algorithmDigestAlgorithm사용할 DigestAlgorithm.
valueString다이제스트를 계산할 입력 문자열 값입니다.
charsetCharset입력 문자 집합을 나타내는 Charset입니다.

리턴

Byte[] - 출력 다이제스트를 나타내는 byte[] 입니다.


computeHmacSha256Signature(value, key)

지정된 키로 HMAC-SHA256을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var input = Utilities.base64Decode("aW5wdXQgdG8gaGFzaA0K") // == base64encode("input to hash")
var key = Utilities.base64Decode("a2V5"); // == base64encode("key")
var signature = Utilities.computeHmacSha256Signature(input, key);
Logger.log(signature);

매개변수

이름유형설명
valueByte[]해시를 생성할 입력 값입니다.
keyByte[]해시를 생성하는 데 사용하는 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeHmacSha256Signature(value, key)

지정된 키로 HMAC-SHA256을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeHmacSha256Signature("this is my input",
                                                      "my key - use a stronger one");
Logger.log(signature);

매개변수

이름유형설명
valueString해시를 생성할 입력 값입니다.
keyString해시를 생성하는 데 사용하는 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeHmacSha256Signature(value, key, charset)

지정된 키 및 문자 집합과 함께 HMAC-SHA256을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeHmacSha256Signature("this is my input",
                                                     "my key - use a stronger one",
                                                     Utilities.Charset.US_ASCII);
Logger.log(signature);

매개변수

이름유형설명
valueString해시를 생성할 입력 값입니다.
keyString해시를 생성하는 데 사용하는 키입니다.
charsetCharset입력 문자 집합을 나타내는 Charset입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeHmacSignature(algorithm, value, key)

지정된 키와 값에 지정된 알고리즘을 사용하여 메시지 인증 코드를 계산합니다.

// This writes an array of bytes to the log.
var input = Utilities.base64Decode("aW5wdXQgdG8gaGFzaA0K") // == base64encode("input to hash")
var key = Utilities.base64Decode("a2V5"); // == base64encode("key")
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_MD5, input, key);
Logger.log(signature);

매개변수

이름유형설명
algorithmMacAlgorithm입력 값을 해싱하는 데 사용할 MacAlgorithm 알고리즘
valueByte[]해시를 생성할 입력 값입니다.
keyByte[]해시를 생성하는 데 사용하는 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeHmacSignature(algorithm, value, key)

지정된 키와 값에 지정된 알고리즘을 사용하여 메시지 인증 코드를 계산합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_MD5,
                                               "input to hash",
                                               "key");
Logger.log(signature);

매개변수

이름유형설명
algorithmMacAlgorithm입력 값을 해싱하는 데 사용할 MacAlgorithm 알고리즘
valueString해시를 생성할 입력 값입니다.
keyString해시를 생성하는 데 사용하는 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeHmacSignature(algorithm, value, key, charset)

지정된 키와 값에 지정된 알고리즘을 사용하여 메시지 인증 코드를 계산합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_MD5,
                                               "input to hash",
                                               "key",
                                               Utilities.Charset.US_ASCII);
Logger.log(signature);

매개변수

이름유형설명
algorithmMacAlgorithm입력 값을 해싱하는 데 사용할 MacAlgorithm 알고리즘
valueString해시를 생성할 입력 값입니다.
keyString해시를 생성하는 데 사용하는 키입니다.
charsetCharset입력 문자 집합을 나타내는 Charset입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeRsaSha1Signature(value, key)

지정된 키로 RSA-SHA1을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeRsaSha1Signature("this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n");
Logger.log(signature);

매개변수

이름유형설명
valueString해시를 생성할 입력 값입니다.
keyString서명을 생성하는 데 사용할 PEM 형식의 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeRsaSha1Signature(value, key, charset)

지정된 키와 문자 집합으로 RSA-SHA1을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeRsaSha1Signature("this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n"
    Utilities.Charset.US_ASCII);
Logger.log(signature);

매개변수

이름유형설명
valueString해시를 생성할 입력 값입니다.
keyString서명을 생성하는 데 사용할 PEM 형식의 키입니다.
charsetCharset입력 문자 집합을 나타내는 Charset입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeRsaSha256Signature(value, key)

지정된 키로 RSA-SHA256을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeRsaSha256Signature("this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n");
Logger.log(signature);

매개변수

이름유형설명
valueString해시를 생성할 입력 값입니다.
keyString서명을 생성하는 데 사용할 PEM 형식의 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeRsaSha256Signature(value, key, charset)

지정된 키로 RSA-SHA256을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeRsaSha256Signature("this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n");
Logger.log(signature);

매개변수

이름유형설명
valueString해시를 생성할 입력 값입니다.
keyString서명을 생성하는 데 사용할 PEM 형식의 키입니다.
charsetCharset입력 문자 집합을 나타내는 Charset입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeRsaSignature(algorithm, value, key)

지정된 키로 지정된 RSA 알고리즘을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeRsaSignature(Utilities.RsaAlgorithm.RSA_SHA_256,
    "this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n");
Logger.log(signature);

매개변수

이름유형설명
algorithmRsaAlgorithm입력 값을 해싱하는 데 사용할 RsaAlgorithm 알고리즘
valueString해시를 생성할 입력 값입니다.
keyString서명을 생성하는 데 사용할 PEM 형식의 키입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


computeRsaSignature(algorithm, value, key, charset)

지정된 키 및 문자 집합으로 지정된 RSA 알고리즘을 사용하여 제공된 값에 서명합니다.

// This writes an array of bytes to the log.
var signature = Utilities.computeRsaSignature(Utilities.RsaAlgorithm.RSA_SHA_256,
    "this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n",
    Utilities.Charset.US_ASCII);
Logger.log(signature);

매개변수

이름유형설명
algorithmRsaAlgorithm입력 값을 해싱하는 데 사용할 RsaAlgorithm 알고리즘
valueString해시를 생성할 입력 값입니다.
keyString서명을 생성하는 데 사용할 PEM 형식의 키입니다.
charsetCharset입력 문자 집합을 나타내는 Charset입니다.

리턴

Byte[] - 출력 서명을 나타내는 byte[] 입니다.


formatDate(date, timeZone, format)

자바 SE SimpleDateFormat 클래스에 설명된 사양에 따라 날짜 형식을 지정합니다. 사양( http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html)을 참조하세요.

// This formats the date as Greenwich Mean Time in the format
// year-month-dateThour-minute-second.
var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'");
Logger.log(formattedDate);

매개변수

이름유형설명
dateDate문자열로 형식을 지정할 Date입니다.
timeZoneString결과의 출력 시간대입니다.
formatStringSimpleDateFormat 사양에 따른 형식입니다.

리턴

String - 형식이 지정된 문자열로 된 입력 날짜입니다.


formatString(template, args)

'%' 스타일 형식 문자열을 사용하여 sprintf와 유사한 문자열 형식을 실행합니다.

// " 123.456000"
Utilities.formatString('%11.6f', 123.456);

// "   abc"
Utilities.formatString('%6s', 'abc');

매개변수

이름유형설명
templateString반환되는 항목을 제어하는 형식 문자열입니다.
argsObject...템플릿의 '%' 자리표시자를 채우는 데 사용할 객체입니다.

리턴

String - 형식이 지정된 문자열입니다.


getUuid()

UUID를 문자열로 가져옵니다 (java.util.UUID.randomUUID() 메서드를 사용하는 것과 동일). 이 식별자는 모든 시간과 공간에서 고유하지 않을 수도 있습니다. 따라서 고유성이 보장되어야 하는 상황에서는 사용하지 마세요.

//This assigns a UUID as a temporary ID for a data object you are creating in your script.
var myDataObject = {
   tempId: Utilities.getUuid();
};

리턴

String - UUID의 문자열 표현입니다.


gzip(blob)

gzip는 제공된 Blob 데이터를 압축하여 새 Blob 객체에 반환합니다.

var textBlob = Utilities.newBlob("Some text to compress using gzip compression");

// Create the compressed blob.
var gzipBlob = Utilities.gzip(textBlob);

매개변수

이름유형설명
blobBlobSourcegzip를 사용하여 압축할 Blob 객체입니다.

리턴

Blob - 압축된 데이터가 포함된 새 Blob입니다.


gzip(blob, name)

gzip는 제공된 Blob 데이터를 압축하여 새 Blob 객체에 반환합니다. 이 메서드 버전에서는 파일 이름을 지정할 수 있습니다.

var textBlob = Utilities.newBlob("Some text to compress using gzip compression");

// Create the compressed blob.
var gzipBlob = Utilities.gzip(textBlob, "text.gz");

매개변수

이름유형설명
blobBlobSourcegzip를 사용하여 압축할 Blob 객체입니다.
nameString생성할 gzip 파일의 이름입니다.

리턴

Blob - 압축된 데이터가 포함된 새 Blob입니다.


newBlob(data)

바이트 배열에서 새 Blob 객체를 만듭니다. blob은 바이너리 데이터를 입력으로 사용하는 많은 Apps Script API에서 사용됩니다.

// Creates a blob object from a byte array.
const data = [71, 79, 79, 71, 76, 69];
const blob = Utilities.newBlob(data);

// Logs the blob data as a string to the console.
console.log(blob.getDataAsString());

매개변수

이름유형설명
dataByte[]blob의 바이트입니다.

리턴

Blob - 새로 생성된 Blob입니다.


newBlob(data, contentType)

바이트 배열 및 콘텐츠 유형에서 새 Blob 객체를 만듭니다. Blob은 바이너리 데이터를 입력으로 사용하는 여러 Apps Script API에서 사용됩니다.

// Declares a byte array.
const data = [71, 79, 79, 71, 76, 69];

// Declares the content type of the blob.
const contentType = 'application/json';

// Creates a blob object from the byte array and content type.
const blob = Utilities.newBlob(data, contentType);

// Logs the blob data as a string to the console.
console.log(blob.getDataAsString());

// Logs the content type of the blob to the console.
console.log(blob.getContentType());

매개변수

이름유형설명
dataByte[]blob의 바이트입니다.
contentTypeStringblob의 콘텐츠 유형이며 null일 수 있습니다.

리턴

Blob - 새로 생성된 Blob입니다.


newBlob(data, contentType, name)

바이트 배열, 콘텐츠 유형, 이름에서 새 Blob 객체를 만듭니다. Blob은 바이너리 데이터를 입력으로 사용하는 많은 Apps Script API에서 사용됩니다.

// Declares a byte array.
const data = [71, 79, 79, 71, 76, 69];

// Declares the content type of the blob.
const contentType = 'application/json';

// Declares the name of the blob.
const name = 'Example blob';

// Creates a blob object from the byte array, content type, and name.
const blob = Utilities.newBlob(data, contentType, name);

// Logs the blob data as a string to the console.
console.log('Blob data:', blob.getDataAsString());

// Logs the content type of the blob to the console.
console.log('Blob content type:', blob.getContentType());

// Logs the name of the blob to the console.
console.log('Blob name:', blob.getName());

매개변수

이름유형설명
dataByte[]blob의 바이트입니다.
contentTypeString- blob의 콘텐츠 유형은 null입니다.
nameStringblob의 이름이며 null일 수 있습니다.

리턴

Blob - 새로 생성된 Blob입니다.


newBlob(data)

문자열에서 새 Blob 객체를 만듭니다. blob은 바이너리 데이터를 입력으로 사용하는 많은 Apps Script API에서 사용됩니다.

// Declares a string for the blob.
const data = 'GOOGLE';

// Creates a blob object from a string.
const blob = Utilities.newBlob(data);

// Logs the blob data in byte array to the console.
console.log('Blob Data:', blob.getBytes());

매개변수

이름유형설명
dataStringUTF-8로 가정되는 blob의 문자열입니다.

리턴

Blob - 새로 생성된 Blob입니다.


newBlob(data, contentType)

문자열과 콘텐츠 유형에서 새 Blob 객체를 만듭니다. Blob은 바이너리 데이터를 입력으로 사용하는 여러 Apps Script API에서 사용됩니다.

// Declares a string for the blob.
const data = 'GOOGLE';

// Declares the content type of blob.
const contentType = 'application/json';

// Creates a blob object from the string and content type.
const blob = Utilities.newBlob(data, contentType);

// Logs the blob data in byte array to the console.
console.log('Blob data:', blob.getBytes());

// Logs the content type of the blob to the console.
console.log(blob.getContentType());

매개변수

이름유형설명
dataStringUTF-8로 가정되는 blob의 문자열입니다.
contentTypeStringblob의 콘텐츠 유형이며 null일 수 있습니다.

리턴

Blob - 새로 생성된 Blob입니다.


newBlob(data, contentType, name)

문자열, 콘텐츠 유형, 이름에서 새 Blob 객체를 만듭니다. Blob은 바이너리 데이터를 입력으로 사용하는 많은 Apps Script API에서 사용됩니다.

// Declares a string for the blob.
const data = 'GOOGLE';

// Declares the content type of the blob.
const contentType = 'application/json';

// Declares the name of the blob.
const name = 'Example blob';

// Create a blob object from the string, content type, and name.
const blob = Utilities.newBlob(data, contentType, name);

// Logs the blob data in byte array to the console.
console.log('Blob data:', blob.getBytes());

// Logs the content type of the blob to the console.
console.log('Blob content type:', blob.getContentType());

// Logs the name of the blob to the console.
console.log('Blob name:', blob.getName());

매개변수

이름유형설명
dataStringUTF-8로 가정되는 blob의 문자열입니다.
contentTypeStringblob의 콘텐츠 유형이며 null일 수 있습니다.
nameStringblob의 이름이며 null일 수 있습니다.

리턴

Blob - 새로 생성된 Blob입니다.


parseCsv(csv)

CSV 문자열의 표 형식 2D 배열 표현을 반환합니다.

// This creates a two-dimensional array of the format [[a, b, c], [d, e, f]]
var csvString = "a,b,c\nd,e,f";
var data = Utilities.parseCsv(csvString);

매개변수

이름유형설명
csvString쉼표로 구분된 값 (CSV) 형식의 한 줄 또는 여러 줄 데이터가 포함된 문자열입니다.

리턴

String[][] - CSV 문자열의 값이 포함된 2차원 배열입니다.


parseCsv(csv, delimiter)

커스텀 구분자를 사용하여 CSV 문자열의 표 형식 2D 배열 표현을 반환합니다.

// This creates a two-dimensional array of the format [[a, b, c], [d, e, f]]
var csvString = "a\tb\tc\nd\te\tf";
var data = Utilities.parseCsv(csvString, '\t');

매개변수

이름유형설명
csvString쉼표로 구분된 값 (CSV) 형식의 한 줄 또는 여러 줄 데이터가 포함된 문자열입니다.
delimiterChar값 사이

리턴

String[][] - CSV 문자열의 값이 포함된 2차원 배열입니다.


parseDate(date, timeZone, format)

Java Standard Edition SimpleDateFormat 클래스에 설명된 사양에 따라 제공된 문자열 날짜를 파싱합니다. 자세한 내용은 자바 SimpleDateFormat 클래스를 참고하세요.

// This set of parameters parses the given string as a date in Greenwich Mean Time, formatted
// as year-month-dateThour-minute-second.
var date = Utilities.parseDate("1970-01-01 00:00:00", "GMT", "yyyy-MM-dd' 'HH:mm:ss");
Logger.log(date);

매개변수

이름유형설명
dateString날짜로 파싱할 문자열 값입니다.
timeZoneString출력 시간대입니다.
formatStringSimpleDateFormat 사양에 따른 날짜 형식입니다.

리턴

Date - 날짜 형식의 입력 문자열.


sleep(milliseconds)

지정된 밀리초 동안 절전 모드로 전환됩니다. 즉시 스크립트가 지정된 밀리초 동안 절전 모드로 전환됩니다. 허용되는 최대값은 300,000 (또는 5분)입니다.

// Creates a blob object from a string.
const data = 'GOOGLE';
const blob = Utilities.newBlob(data);

// Puts the script to sleep for 10,000 milliseconds (10 seconds).
Utilities.sleep(10000);

// Logs the blob data in byte array to the console.
console.log(blob.getBytes());

매개변수

이름유형설명
millisecondsInteger절전 모드 전환 시간(밀리초)입니다.

ungzip(blob)

Blob 객체의 압축을 풀고 압축되지 않은 데이터가 포함된 Blob를 반환합니다.

var textBlob = Utilities.newBlob("Some text to compress using gzip compression");

// Create the compressed blob.
var gzipBlob = Utilities.gzip(textBlob, "text.gz");

// Uncompress the data.
var uncompressedBlob = Utilities.ungzip(gzipBlob);

매개변수

이름유형설명
blobBlobSource압축된 데이터의 Blob입니다.

리턴

Blob - 압축 해제된 데이터를 나타내는 Blob입니다.


unzip(blob)

zip 파일을 나타내는 Blob을 가져와 구성요소 파일을 반환합니다.

var googleFavIconUrl = "https://www.google.com/favicon.ico";
var googleLogoUrl = "https://www.google.com/images/srpr/logo3w.png";

// Fetch the Google favicon.ico file and get the Blob data
var faviconBlob = UrlFetchApp.fetch(googleFavIconUrl).getBlob();
var logoBlob = UrlFetchApp.fetch(googleLogoUrl).getBlob();

// zip now references a blob containing an archive of both faviconBlob and logoBlob
var zip = Utilities.zip([faviconBlob, logoBlob], "google_images.zip");

// This now unzips the blobs
var files = Utilities.unzip(zip);

매개변수

이름유형설명
blobBlobSourceZIP 파일 blob입니다.

리턴

Blob[] - 구성요소 blob을 나타내는 Blob[] 으로, 각각 zip 안의 전체 경로로 이름이 지정됩니다.


zip(blobs)

전달된 Blob의 데이터를 포함하는 ZIP 파일인 새 Blob 객체를 만듭니다.

var googleFavIconUrl = "https://www.google.com/favicon.ico";
var googleLogoUrl = "https://www.google.com/images/srpr/logo3w.png";

// Fetch the Google favicon.ico file and get the Blob data
var faviconBlob = UrlFetchApp.fetch(googleFavIconUrl).getBlob();
var logoBlob = UrlFetchApp.fetch(googleLogoUrl).getBlob();

// zip now references a blob containing an archive of both faviconBlob and logoBlob
var zip = Utilities.zip([faviconBlob, logoBlob]);

매개변수

이름유형설명
blobsBlobSource[]압축할 blob의 배열입니다.

리턴

Blob - 입력을 아카이브로 포함하는 새 blob입니다.


zip(blobs, name)

전달된 Blob의 데이터를 포함하는 ZIP 파일인 새 Blob 객체를 만듭니다. 이 메서드 버전에서는 파일 이름을 지정할 수 있습니다.

var googleFavIconUrl = "https://www.google.com/favicon.ico";
var googleLogoUrl = "https://www.google.com/images/srpr/logo3w.png";

// Fetch the Google favicon.ico file and get the Blob data
var faviconBlob = UrlFetchApp.fetch(googleFavIconUrl).getBlob();
var logoBlob = UrlFetchApp.fetch(googleLogoUrl).getBlob();

// zip now references a blob containing an archive of both faviconBlob and logoBlob
var zip = Utilities.zip([faviconBlob, logoBlob], "google_images.zip");

매개변수

이름유형설명
blobsBlobSource[]압축할 blob의 배열입니다.
nameString생성할 ZIP 파일의 이름입니다.

리턴

Blob - 입력을 아카이브로 포함하는 새 blob입니다.

지원 중단된 메서드