บริการนี้มอบยูทิลิตีสำหรับการเข้ารหัส/ถอดรหัสสตริง การจัดรูปแบบวันที่ การควบคุม JSON และงานอื่นๆ
พร็อพเพอร์ตี้
พร็อพเพอร์ตี้ | Type | คำอธิบาย |
---|---|---|
Charset | Charset | |
DigestAlgorithm | DigestAlgorithm | |
MacAlgorithm | MacAlgorithm | |
RsaAlgorithm | RsaAlgorithm |
วิธีการ
วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
---|---|---|
base64Decode(encoded) | Byte[] | ถอดรหัสสตริงที่เข้ารหัส base-64 เป็นอาร์เรย์ไบต์ UTF-8 |
base64Decode(encoded, charset) | Byte[] | ถอดรหัสสตริงที่เข้ารหัส base-64 เป็นอาร์เรย์ไบต์ในชุดอักขระเฉพาะ |
base64DecodeWebSafe(encoded) | Byte[] | ถอดรหัสสตริงที่เข้ารหัสแบบ Web-safe แบบ 64 เป็นอาร์เรย์ไบต์ UTF-8 |
base64DecodeWebSafe(encoded, charset) | Byte[] | ถอดรหัสสตริงที่เข้ารหัสแบบเว็บปลอดภัยฐาน 64 เป็นอาร์เรย์ไบต์ในชุดอักขระเฉพาะ |
base64Encode(data) | String | สร้างสตริงที่เข้ารหัส base-64 จากอาร์เรย์ไบต์ที่ระบุ |
base64Encode(data) | String | สร้างสตริงที่เข้ารหัส base-64 จากสตริงที่ระบุ |
base64Encode(data, charset) | String | สร้างสตริงที่เข้ารหัสเลขฐาน 64 จากสตริงที่ระบุในชุดอักขระเฉพาะ |
base64EncodeWebSafe(data) | String | สร้างสตริงที่เข้ารหัสแบบ Web-safe แบบ Base-64 จากอาร์เรย์ไบต์ที่ระบุ |
base64EncodeWebSafe(data) | String | สร้างสตริงที่เข้ารหัสแบบ Web-safe แบบ Base-64 จากสตริงที่ระบุ |
base64EncodeWebSafe(data, charset) | String | สร้างสตริงที่เข้ารหัสแบบ Web-safe แบบ Base64 จากสตริงที่ระบุในชุดอักขระที่เฉพาะเจาะจง |
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 | จัดรูปแบบวันที่ตามข้อกำหนดที่อธิบายไว้ในคลาส SimpleDateFormat Java SE |
formatString(template, args) | String | ดำเนินการจัดรูปแบบสตริงเหมือน sprintf โดยใช้สตริงรูปแบบ "%" |
getUuid() | String | รับ UUID เป็นสตริง (เทียบเท่ากับการใช้เมธอด java.util.UUID.randomUUID() ) |
gzip(blob) | Blob | gzip - บีบอัดข้อมูล Blob ที่ระบุและส่งคืนในออบเจ็กต์ Blob ใหม่ |
gzip(blob, name) | Blob | gzip - บีบอัดข้อมูล 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[][] | แสดงผลการแสดงอาร์เรย์ 2 มิติแบบตารางของสตริง CSV |
parseCsv(csv, delimiter) | String[][] | แสดงผลการแสดงอาร์เรย์ 2 มิติแบบตารางของสตริง CSV โดยใช้ตัวคั่นที่กำหนดเอง |
parseDate(date, timeZone, format) | Date | แยกวิเคราะห์วันที่ของสตริงที่ระบุตามข้อกำหนดที่อธิบายไว้ในคลาส SimpleDateFormat ฉบับมาตรฐาน Java |
sleep(milliseconds) | void | การนอนหลับตามจำนวนมิลลิวินาทีที่ระบุ |
ungzip(blob) | Blob | ยกเลิกการบีบอัดออบเจ็กต์ Blob และแสดงผล Blob ที่มีข้อมูลที่ไม่ได้บีบอัด |
unzip(blob) | Blob[] | ใช้ Blob ที่เป็นตัวแทนของไฟล์ ZIP และส่งคืนไฟล์คอมโพเนนต์ |
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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
encoded | String | อาร์เรย์ของไบต์ข้อมูลที่จะถอดรหัส |
รีเทิร์น
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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
encoded | String | สตริงข้อมูลที่จะถอดรหัส |
charset | Charset | Charset ที่ระบุชุดอักขระของอินพุต |
รีเทิร์น
Byte[]
— ข้อมูลดิบที่แสดงโดยอาร์กิวเมนต์ที่เข้ารหัส base-64 เป็นอาร์เรย์ไบต์
base64DecodeWebSafe(encoded)
ถอดรหัสสตริงที่เข้ารหัสแบบ Web-safe แบบ 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
encoded | String | อาร์เรย์ของไบต์ข้อมูลที่ปลอดภัยบนเว็บสำหรับถอดรหัส |
รีเทิร์น
Byte[]
— ข้อมูลดิบที่แสดงโดยอาร์กิวเมนต์ที่เข้ารหัสแบบ Web-safe แบบ Base-64 เป็นไบต์อาร์เรย์
base64DecodeWebSafe(encoded, charset)
ถอดรหัสสตริงที่เข้ารหัสแบบเว็บปลอดภัยฐาน 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
encoded | String | สตริงข้อมูลความปลอดภัยของเว็บที่จะถอดรหัส |
charset | Charset | Charset ที่ระบุชุดอักขระของอินพุต |
รีเทิร์น
Byte[]
— ข้อมูลดิบที่แสดงโดยอาร์กิวเมนต์ที่เข้ารหัสแบบ Web-safe แบบ 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | Byte[] | 1 ไบต์[] ของข้อมูลที่จะเข้ารหัส |
รีเทิร์น
String
— การแทนค่าที่เข้ารหัสแบบ Base64 ของข้อมูลที่ส่งผ่าน
base64Encode(data)
สร้างสตริงที่เข้ารหัส base-64 จากสตริงที่ระบุ Base64 คือการเข้ารหัสที่นิยมใช้กันทั่วไปโดยใช้เครื่องมือต่างๆ ที่ไม่ยอมรับข้อมูลไบนารี Base 64 มีการใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, HTTP หรือในเอกสาร XML
// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log. var encoded = Utilities.base64Encode("A string here"); Logger.log(encoded);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงที่จะเข้ารหัส |
รีเทิร์น
String
— การแทนค่าที่เข้ารหัสแบบ Base-64 ของสตริงอินพุต
base64Encode(data, charset)
สร้างสตริงที่เข้ารหัสเลขฐาน 64 จากสตริงที่ระบุในชุดอักขระเฉพาะ ชุดอักขระเป็นวิธีการเข้ารหัสอักขระเพื่อให้ทำการเข้ารหัสได้ ซึ่งมักทำในรูปแบบไบนารี ซึ่งโดยทั่วไปจะไม่เข้ากันกับโปรโตคอลการส่งข้อมูลบางอย่าง เพื่อให้ข้อมูลที่เข้ากันได้ โดยปกติไฟล์เหล่านั้นจะได้รับการเข้ารหัสเป็นเลขฐาน 64 ซึ่งเป็นการเข้ารหัสทั่วไปที่ได้รับการยอมรับโดยใช้เครื่องมือต่างๆ ที่ไม่ยอมรับข้อมูลไบนารี 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงข้อมูลที่จะเข้ารหัส |
charset | Charset | Charset ที่ระบุชุดอักขระของอินพุต |
รีเทิร์น
String
— การแทนค่าที่เข้ารหัส base-64 ของสตริงอินพุตด้วย Charset
ที่ระบุ
base64EncodeWebSafe(data)
สร้างสตริงที่เข้ารหัสแบบ Web-safe แบบ Base-64 จากอาร์เรย์ไบต์ที่ระบุ Base64 เป็นการเข้ารหัสทั่วไปที่เครื่องมือหลายประเภทยอมรับข้อมูลไบนารีไม่ได้ Base 64 Web-safe โดยปกติจะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | Byte[] | อาร์เรย์ของไบต์ข้อมูลที่จะเข้ารหัส |
รีเทิร์น
String
— การนำเสนอที่เข้ารหัสแบบ Web-safe แบบ Base64 ของข้อมูลที่ส่งผ่าน
base64EncodeWebSafe(data)
สร้างสตริงที่เข้ารหัสแบบ Web-safe แบบ Base-64 จากสตริงที่ระบุ Base64 คือการเข้ารหัสที่นิยมใช้กันทั่วไปโดยใช้เครื่องมือต่างๆ ที่ไม่ยอมรับข้อมูลไบนารี Base 64 Web-safe โดยปกติจะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, HTTP หรือในเอกสาร XML
// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log. var encoded = Utilities.base64EncodeWebSafe("A string here"); Logger.log(encoded);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงที่จะเข้ารหัส |
รีเทิร์น
String
— สตริงอินพุตที่เข้ารหัสแบบเว็บ-ปลอดภัยฐาน 64
base64EncodeWebSafe(data, charset)
สร้างสตริงที่เข้ารหัสแบบ Web-safe แบบ Base64 จากสตริงที่ระบุในชุดอักขระที่เฉพาะเจาะจง ชุดอักขระเป็นวิธีการเข้ารหัสอักขระเพื่อให้ทำการเข้ารหัสได้ ซึ่งโดยทั่วไปจะทำในรูปแบบไบนารี ซึ่งโดยทั่วไปเข้ากันไม่ได้กับโปรโตคอลการส่งข้อมูลบางประเภท โดยทั่วไปข้อมูลเหล่านี้จะมีการเข้ารหัสโดยทั่วไปใน Base 64 ซึ่งเป็นการเข้ารหัสทั่วไปที่เครื่องมือหลายประเภทยอมรับข้อมูลไบนารีไม่ได้ Base 64 Web-safe โดยปกติจะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงข้อมูลที่จะเข้ารหัส |
charset | Charset | Charset ที่ระบุชุดอักขระของอินพุต |
รีเทิร์น
String
— การนำเสนอที่เข้ารหัสแบบ Web-safe แบบ Base-64 ของสตริงอินพุตที่มี Charset
ที่ระบุ
computeDigest(algorithm, value)
คำนวณไดเจสต์โดยใช้อัลกอริทึมที่ระบุในค่า Byte[]
ที่ระบุ
var input = Utilities.base64Decode("aW5wdXQgdG8gaGFzaA0K") // == base64encode("input to hash") var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, input); Logger.log(digest);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | DigestAlgorithm | DigestAlgorithm เพื่อใช้งาน |
value | Byte[] | ค่าสตริงอินพุตที่จะคํานวณไดเจสต์ |
รีเทิร์น
Byte[]
— ไบต์[] ที่แสดงถึงไดเจสต์เอาต์พุต
computeDigest(algorithm, value)
คำนวณไดเจสต์โดยใช้อัลกอริทึมที่ระบุในค่า String
ที่ระบุ
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, "input to hash"); Logger.log(digest);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | DigestAlgorithm | DigestAlgorithm เพื่อใช้งาน |
value | String | ค่าสตริงอินพุตที่จะคํานวณไดเจสต์ |
รีเทิร์น
Byte[]
— ไบต์[] ที่แสดงถึงไดเจสต์เอาต์พุต
computeDigest(algorithm, value, charset)
คำนวณไดเจสต์โดยใช้อัลกอริทึมที่ระบุในค่า String
ที่ระบุด้วยชุดอักขระที่กำหนด
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, "input to hash", Utilities.Charset.US_ASCII); Logger.log(digest);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | DigestAlgorithm | DigestAlgorithm เพื่อใช้งาน |
value | String | ค่าสตริงอินพุตที่จะคํานวณไดเจสต์ |
charset | Charset | Charset แสดงชุดอักขระอินพุต |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | Byte[] | ค่าอินพุตที่จะสร้างแฮช |
key | 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่ใช้สร้างแฮช |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่ใช้สร้างแฮช |
charset | Charset | Charset แสดงชุดอักขระอินพุต |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | MacAlgorithm | อัลกอริทึม MacAlgorithm ที่จะใช้เพื่อแฮชค่าอินพุต |
value | Byte[] | ค่าอินพุตที่จะสร้างแฮช |
key | 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | MacAlgorithm | อัลกอริทึม MacAlgorithm ที่จะใช้เพื่อแฮชค่าอินพุต |
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่ใช้สร้างแฮช |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | MacAlgorithm | อัลกอริทึม MacAlgorithm ที่จะใช้เพื่อแฮชค่าอินพุต |
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่ใช้สร้างแฮช |
charset | Charset | Charset แสดงชุดอักขระอินพุต |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่จัดรูปแบบ PEM เพื่อใช้สร้างลายเซ็น |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่จัดรูปแบบ PEM เพื่อใช้สร้างลายเซ็น |
charset | Charset | Charset แสดงชุดอักขระอินพุต |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่จัดรูปแบบ PEM เพื่อใช้สร้างลายเซ็น |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่จัดรูปแบบ PEM เพื่อใช้สร้างลายเซ็น |
charset | Charset | Charset แสดงชุดอักขระอินพุต |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | RsaAlgorithm | อัลกอริทึม RsaAlgorithm ที่จะใช้เพื่อแฮชค่าอินพุต |
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่จัดรูปแบบ PEM เพื่อใช้สร้างลายเซ็น |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
algorithm | RsaAlgorithm | อัลกอริทึม RsaAlgorithm ที่จะใช้เพื่อแฮชค่าอินพุต |
value | String | ค่าอินพุตที่จะสร้างแฮช |
key | String | คีย์ที่จัดรูปแบบ PEM เพื่อใช้สร้างลายเซ็น |
charset | Charset | Charset แสดงชุดอักขระอินพุต |
รีเทิร์น
Byte[]
— ไบต์[] ที่แสดงถึงลายเซ็นเอาต์พุต
formatDate(date, timeZone, format)
จัดรูปแบบวันที่ตามข้อกำหนดที่อธิบายไว้ในคลาส SimpleDateFormat Java SE โปรดดูข้อกำหนดที่ 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
date | Date | Date เพื่อจัดรูปแบบเป็นสตริง |
timeZone | String | เขตเวลาสำหรับเอาต์พุตของผลการค้นหา |
format | String | รูปแบบตามข้อกำหนดของ SimpleDateFormat |
รีเทิร์น
String
— วันที่ที่ป้อนเป็นสตริงที่จัดรูปแบบ
formatString(template, args)
ดำเนินการจัดรูปแบบสตริงเหมือน sprintf
โดยใช้สตริงรูปแบบ "%"
// " 123.456000" Utilities.formatString('%11.6f', 123.456); // " abc" Utilities.formatString('%6s', 'abc');
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
template | String | สตริงรูปแบบที่ควบคุมผลลัพธ์ |
args | Object... | ออบเจ็กต์ที่จะใช้เพื่อเติมตัวยึดตำแหน่ง "%" ในเทมเพลต |
รีเทิร์น
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
blob | BlobSource | ออบเจ็กต์ Blob ที่จะบีบอัดโดยใช้ gzip |
รีเทิร์น
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");
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
blob | BlobSource | ออบเจ็กต์ Blob ที่จะบีบอัดโดยใช้ gzip |
name | String | ชื่อของไฟล์ gzip ที่จะสร้าง |
รีเทิร์น
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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | Byte[] | ไบต์ของ Blob |
รีเทิร์น
Blob
— Blob ที่สร้างใหม่
newBlob(data, contentType)
สร้างออบเจ็กต์ Blob ใหม่จากอาร์เรย์ไบต์และประเภทเนื้อหา มีการใช้ Blob ใน API ของ Apps Script จำนวนมากที่รับข้อมูลไบนารีเป็นอินพุต
// 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | Byte[] | ไบต์ของ Blob |
contentType | String | ประเภทเนื้อหาของ Blob - อาจเป็น 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | Byte[] | ไบต์ของ Blob |
contentType | String | - ประเภทเนื้อหาของ Blob - สามารถเป็น null |
name | String | ชื่อของ BLOB สามารถเป็น 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงสำหรับ BLOB ถือว่าเป็น UTF-8 |
รีเทิร์น
Blob
— Blob ที่สร้างใหม่
newBlob(data, contentType)
สร้างออบเจ็กต์ Blob ใหม่จากสตริงและประเภทเนื้อหา มีการใช้ Blob ใน API ของ Apps Script จำนวนมากที่รับข้อมูลไบนารีเป็นอินพุต
// 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงสำหรับ BLOB ถือว่าเป็น UTF-8 |
contentType | String | ประเภทเนื้อหาของ Blob - อาจเป็น 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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงสำหรับ BLOB ถือว่าเป็น UTF-8 |
contentType | String | ประเภทเนื้อหาของ Blob - อาจเป็น null |
name | String | ชื่อของ BLOB สามารถเป็น null ได้ |
รีเทิร์น
Blob
— Blob ที่สร้างใหม่
parseCsv(csv)
แสดงผลการแสดงอาร์เรย์ 2 มิติแบบตารางของสตริง CSV
// 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
csv | String | สตริงที่มีข้อมูลบรรทัดเดียวหรือหลายบรรทัดในรูปแบบค่าที่คั่นด้วยคอมมา (CSV) |
รีเทิร์น
String[][]
— อาร์เรย์ 2 มิติที่มีค่าในสตริง CSV
parseCsv(csv, delimiter)
แสดงผลการแสดงอาร์เรย์ 2 มิติแบบตารางของสตริง CSV โดยใช้ตัวคั่นที่กำหนดเอง
// 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');
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
csv | String | สตริงที่มีข้อมูลบรรทัดเดียวหรือหลายบรรทัดในรูปแบบค่าที่คั่นด้วยคอมมา (CSV) |
delimiter | Char | ระหว่างค่า |
รีเทิร์น
String[][]
— อาร์เรย์ 2 มิติที่มีค่าในสตริง CSV
parseDate(date, timeZone, format)
แยกวิเคราะห์วันที่ของสตริงที่ระบุตามข้อกำหนดที่อธิบายไว้ในคลาส SimpleDateFormat
ฉบับมาตรฐาน Java ดูข้อมูลเพิ่มเติมได้ที่คลาส SimpleDateFormat
ของ Java
// 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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
date | String | ค่าสตริงที่จะแยกวิเคราะห์เป็นวันที่ |
timeZone | String | เขตเวลาเอาต์พุต |
format | String | รูปแบบวันที่ตามข้อกำหนดของ SimpleDateFormat |
รีเทิร์น
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());
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
milliseconds | Integer | ระยะเวลาเป็นมิลลิวินาทีก่อนเข้าสู่โหมดสลีป |
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
blob | BlobSource | Blob ของข้อมูลที่บีบอัด |
รีเทิร์น
unzip(blob)
ใช้ Blob ที่เป็นตัวแทนของไฟล์ ZIP และส่งคืนไฟล์คอมโพเนนต์
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);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
blob | BlobSource | Blob ของไฟล์ ZIP |
รีเทิร์น
Blob[]
— A 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]);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
blobs | BlobSource[] | มู้ดมากมายให้ซิป |
รีเทิร์น
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");
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
blobs | BlobSource[] | มู้ดมากมายให้ซิป |
name | String | ชื่อของไฟล์ ZIP ที่จะสร้าง |
รีเทิร์น
Blob
— Blob ใหม่ที่มีอินพุตเป็นที่เก็บถาวร