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)StringJava SE SimpleDateFormat 클래스에 설명된 사양에 따라 날짜 형식을 지정합니다.
formatString(template, args)String'%' 스타일 형식 문자열을 사용하여 sprintf와 유사한 문자열 형식을 지정합니다.
getUuid()String문자열로 UUID를 가져옵니다 (java.util.UUID.randomUUID() 메서드를 사용하는 것과 동일).
gzip(blob)Blob제공된 Blob 데이터를 gzip로 압축하고 새 Blob 객체로 반환합니다.
gzip(blob, name)Blob제공된 Blob 데이터를 gzip로 압축하고 새 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 グループ"
const base64data = 'R29vZ2xlIOOCsOODq+ODvOODlw==';

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

// If you 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 グループ"
const base64data = 'R29vZ2xlIOOCsOODq+ODvOODlw==';

const 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 you 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 グループ"
const base64data = 'R29vZ2xlIOOCsOODq-ODvOODlw==';

const 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 you 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 グループ"
const base64data = 'R29vZ2xlIOOCsOODq-ODvOODlw==';

const 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 you 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는 바이너리 데이터를 허용하지 않는 다양한 도구에서 허용되는 일반적인 인코딩입니다. Base 64는 이메일, HTTP와 같은 인터넷 프로토콜이나 XML 문서에서 일반적으로 사용됩니다.

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

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

매개변수

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

리턴

String - 전달된 데이터의 base-64 인코딩 표현입니다.


base64Encode(data)

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

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

매개변수

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

리턴

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


base64Encode(data, charset)

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

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

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

매개변수

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

리턴

String: 지정된 Charset이 있는 입력 문자열의 base-64 인코딩 표현입니다.


base64EncodeWebSafe(data)

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

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

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

매개변수

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

리턴

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


base64EncodeWebSafe(data)

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

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

매개변수

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

리턴

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


base64EncodeWebSafe(data, charset)

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

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

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

매개변수

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

리턴

String - 지정된 Charset이 있는 입력 문자열의 base-64 웹 보안 인코딩 표현입니다.


computeDigest(algorithm, value)

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

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

매개변수

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

리턴

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


computeDigest(algorithm, value)

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

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

매개변수

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

리턴

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


computeDigest(algorithm, value, charset)

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

const 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.
const input = Utilities.base64Decode(
    'aW5wdXQgdG8gaGFzaA0K');                 // == base64encode("input to hash")
const key = Utilities.base64Decode('a2V5');  // == base64encode("key")
const 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.
const 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.
const 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.
const input = Utilities.base64Decode(
    'aW5wdXQgdG8gaGFzaA0K');                 // == base64encode("input to hash")
const key = Utilities.base64Decode('a2V5');  // == base64encode("key")
const 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.
const 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.
const 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.
const signature = Utilities.computeRsaSha1Signature(
    'this is my input',
    PropertiesService.getScriptProperties().getProperty('YOUR_PRIVATE_KEY'),
);
Logger.log(signature);

매개변수

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

리턴

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


computeRsaSha1Signature(value, key, charset)

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

// This writes an array of bytes to the log.
const signature = Utilities.computeRsaSha1Signature(
    'this is my input',
    PropertiesService.getScriptProperties().getProperty('YOUR_PRIVATE_KEY'),
    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.
const signature = Utilities.computeRsaSha256Signature(
    'this is my input',
    PropertiesService.getScriptProperties().getProperty('YOUR_PRIVATE_KEY'),
);
Logger.log(signature);

매개변수

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

리턴

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


computeRsaSha256Signature(value, key, charset)

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

// This writes an array of bytes to the log.
const signature = Utilities.computeRsaSha256Signature(
    'this is my input',
    PropertiesService.getScriptProperties().getProperty('YOUR_PRIVATE_KEY'),
);
Logger.log(signature);

매개변수

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

리턴

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


computeRsaSignature(algorithm, value, key)

제공된 값에 지정된 RSA 알고리즘과 주어진 키를 사용하여 서명합니다.

// This writes an array of bytes to the log.
const signature = Utilities.computeRsaSignature(
    Utilities.RsaAlgorithm.RSA_SHA_256,
    'this is my input',
    PropertiesService.getScriptProperties().getProperty('YOUR_PRIVATE_KEY'),
);
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.
const signature = Utilities.computeRsaSignature(
    Utilities.RsaAlgorithm.RSA_SHA_256,
    'this is my input',
    PropertiesService.getScriptProperties().getProperty('YOUR_PRIVATE_KEY'),
    Utilities.Charset.US_ASCII,
);
Logger.log(signature);

매개변수

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

리턴

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


formatDate(date, timeZone, format)

Java 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.
const 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.
const myDataObject = {
  tempId: Utilities.getUuid(),
};

리턴

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


gzip(blob)

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

const textBlob = Utilities.newBlob(
    'Some text to compress using gzip compression',
);

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

매개변수

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

리턴

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


gzip(blob, name)

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

const textBlob = Utilities.newBlob(
    'Some text to compress using gzip compression',
);

// Create the compressed blob.
const 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일 수 있습니다.
nameString블롭의 이름입니다. 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());

매개변수

이름유형설명
dataString블롭의 문자열입니다. UTF-8로 가정합니다.

리턴

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());

매개변수

이름유형설명
dataString블롭의 문자열입니다(UTF-8로 가정).
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());

매개변수

이름유형설명
dataString블롭의 문자열입니다(UTF-8로 가정).
contentTypeStringblob의 콘텐츠 유형입니다. null일 수 있습니다.
nameString블롭의 이름입니다. null일 수 있습니다.

리턴

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


parseCsv(csv)

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

// This creates a two-dimensional array of the format [[a, b, c], [d, e, f]]
const csvString = 'a,b,c\nd,e,f';
const 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]]
const csvString = 'a\tb\tc\nd\te\tf';
const data = Utilities.parseCsv(csvString, '\t');

매개변수

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

리턴

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


parseDate(date, timeZone, format)

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

// This set of parameters parses the given string as a date in Greenwich Mean
// Time, formatted as year-month-dateThour-minute-second.
const 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를 반환합니다.

const textBlob = Utilities.newBlob(
    'Some text to compress using gzip compression',
);

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

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

매개변수

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

리턴

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


unzip(blob)

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

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

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

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

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

매개변수

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

리턴

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


zip(blobs)

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

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

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

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

매개변수

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

리턴

Blob: 입력을 보관 파일로 포함하는 새 blob입니다.


zip(blobs, name)

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

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

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

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

매개변수

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

리턴

Blob: 입력을 보관 파일로 포함하는 새 blob입니다.

지원 중단된 메서드