บริการนี้มียูทิลิตีสําหรับการเข้ารหัส/การถอดรหัสสตริง การจัดรูปแบบวันที่ การจัดการ JSON และงานเบ็ดเตล็ดอื่นๆ
พร็อพเพอร์ตี้
พร็อพเพอร์ตี้ | Type | คำอธิบาย |
---|---|---|
Charset | Charset | |
DigestAlgorithm | DigestAlgorithm | |
MacAlgorithm | MacAlgorithm | |
RsaAlgorithm | RsaAlgorithm |
วิธีการ
วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
---|---|---|
base64Decode(encoded) | Byte[] | ถอดรหัสสตริงฐาน 64 ที่เข้ารหัสเป็นอาร์เรย์ UTF-8 ไบต์ |
base64Decode(encoded, charset) | Byte[] | ถอดรหัสสตริงฐาน 64 ที่เข้ารหัสเป็นไบต์ชุดอักขระที่กําหนด |
base64DecodeWebSafe(encoded) | Byte[] | ถอดรหัสสตริงแบบ Web-Safe ที่เข้ารหัสฐาน 64 เป็นอาร์เรย์ UTF-8 ไบต์ |
base64DecodeWebSafe(encoded, charset) | Byte[] | ถอดรหัสสตริงที่ปลอดภัยต่อเว็บฐาน 64 เป็นอาร์เรย์ไบต์ในชุดอักขระเฉพาะ |
base64Encode(data) | String | สร้างสตริงที่เข้ารหัสฐาน 64 จากอาร์เรย์ไบต์ที่ระบุ |
base64Encode(data) | String | สร้างสตริงที่เข้ารหัสฐาน 64 จากสตริงที่ระบุ |
base64Encode(data, charset) | String | สร้างสตริงที่เข้ารหัสฐาน 64 จากสตริงที่ระบุในชุดอักขระที่เฉพาะเจาะจง |
base64EncodeWebSafe(data) | String | สร้างสตริงที่เข้ารหัส Web-Safe ฐาน 64 จากอาร์เรย์ไบต์ที่ระบุ |
base64EncodeWebSafe(data) | String | สร้างสตริงที่เข้ารหัสฐานเว็บที่ปลอดภัย 64 จากสตริงที่ระบุ |
base64EncodeWebSafe(data, charset) | String | สร้างสตริงที่เข้ารหัสลับฐานเว็บ 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 | จัดรูปแบบวันที่ตามข้อกําหนดที่อธิบายไว้ในคลาส Java SE SimpleDateFormat |
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[][] | แสดงผลค่าอาร์เรย์ CSV แบบ 2 มิติของสตริง CSV |
parseCsv(csv, delimiter) | String[][] | แสดงผลค่าอาร์เรย์ CSV แบบ 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)
ถอดรหัสสตริงฐาน 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)
ถอดรหัสสตริงฐาน 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[]
— ข้อมูลดิบที่แสดงโดยอาร์กิวเมนต์ที่เข้ารหัสลับซึ่งอิงจากเว็บฐาน 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[]
— ข้อมูลดิบที่แสดงโดยอาร์กิวเมนต์ที่เข้ารหัสลับซึ่งอิงจากเว็บฐาน 64 เป็นอาร์เรย์ไบต์
base64Encode(data)
สร้างสตริงที่เข้ารหัสฐาน 64 จากอาร์เรย์ไบต์ที่ระบุ Base66 เป็นการเข้ารหัสทั่วไปที่ได้รับการยอมรับโดยใช้เครื่องมือที่หลากหลายที่ไม่สามารถยอมรับข้อมูลไบนารีได้ Base66 มักจะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, 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[] | ไบต์ของข้อมูล[] ที่จะเข้ารหัส |
ขากลับ
String
— การแสดงที่เข้ารหัสฐาน 64 ของข้อมูลที่ส่ง
base64Encode(data)
สร้างสตริงที่เข้ารหัสฐาน 64 จากสตริงที่ระบุ Base66 คือการเข้ารหัสทั่วไปที่ เครื่องมือต่างๆ ยอมรับไม่ได้สําหรับข้อมูลไบนารี โดยทั่วไปฐาน 64 จะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, HTTP หรือเอกสาร XML
// Writes 'QSBzdHJpbmcgaGVyZQ==' to the log. var encoded = Utilities.base64Encode("A string here"); Logger.log(encoded);
พารามิเตอร์
ชื่อ | Type | คำอธิบาย |
---|---|---|
data | String | สตริงที่จะเข้ารหัส |
ขากลับ
String
— การแสดงสตริงอินพุตที่เข้ารหัสฐาน 64
base64Encode(data, charset)
สร้างสตริงที่เข้ารหัสฐาน 64 จากสตริงที่ระบุในชุดอักขระที่เฉพาะเจาะจง ชุดอักขระคือวิธีการเข้ารหัสอักขระเพื่อให้สามารถเข้ารหัสได้ ซึ่งมักเกิดขึ้นในรูปแบบไบนารี ซึ่งโดยทั่วไปจะไม่สามารถทํางานร่วมกับโปรโตคอลการส่งข้อมูลบางรูปแบบได้ เพื่อทําให้ข้อมูลเข้ากันได้ โดยทั่วไปจะเข้ารหัสเป็นเลขฐาน 64 ซึ่งเป็นการเข้ารหัสทั่วไปที่ได้รับการยอมรับโดยใช้เครื่องมือต่างๆ ที่ไม่ยอมรับข้อมูลไบนารี Base66 มักจะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, 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
— การแสดงสตริงอินพุตที่เข้ารหัสฐาน 64 โดยใช้ Charset
ที่ระบุ
base64EncodeWebSafe(data)
สร้างสตริงที่เข้ารหัส Web-Safe ฐาน 64 จากอาร์เรย์ไบต์ที่ระบุ Base66 คือการเข้ารหัสทั่วไปที่เครื่องมือต่างๆ ยอมรับซึ่งไม่ได้รับการยอมรับจากไบนารี โดยทั่วไปแล้ว Web Safe Base 64 จะใช้ในโปรโตคอลอินเทอร์เน็ต เช่น อีเมล, 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
— การนําเสนอที่เข้ารหัสซึ่งเข้ารหัสแบบเว็บ-ฐาน 64 ของข้อมูลที่ส่ง
base64EncodeWebSafe(data)
สร้างสตริงที่เข้ารหัสฐานเว็บที่ปลอดภัย 64 จากสตริงที่ระบุ Base66 เป็นการเข้ารหัสทั่วไปที่ได้รับการยอมรับโดยใช้เครื่องมือที่หลากหลายที่ไม่สามารถยอมรับข้อมูลไบนารีได้ 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)
สร้างสตริงที่เข้ารหัสลับฐานเว็บ 64 จากสตริงที่ระบุในชุดอักขระที่เฉพาะเจาะจง ชุดอักขระเป็นวิธีการเข้ารหัสอักขระเพื่อให้สามารถเข้ารหัสได้ ซึ่งมักอยู่ในรูปแบบไบนารี ซึ่งโดยทั่วไปจะไม่สามารถทํางานร่วมกับโปรโตคอลการส่งข้อมูลบางอย่างได้ เพื่อทําให้ข้อมูลเข้ากันได้ โดยทั่วไปจะถูกเข้ารหัสเป็นฐาน 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
— การแสดงสตริงอินพุตที่เข้ารหัสลับฐานเว็บ 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)
จัดรูปแบบวันที่ตามข้อกําหนดที่อธิบายไว้ในคลาส 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. 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 ถูกใช้ใน 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());
พารามิเตอร์
ชื่อ | 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 ถูกใช้ใน 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());
พารามิเตอร์
ชื่อ | 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)
แสดงผลค่าอาร์เรย์ 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)
แสดงผลค่าอาร์เรย์ CSV แบบ 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[]
— 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
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[] | อาร์เรย์ของ Blob ที่จะบีบอัด |
name | String | ชื่อไฟล์ ZIP ที่จะสร้าง |
ขากลับ
Blob
BLOB ใหม่ซึ่งมีอินพุตเป็นที่เก็บถาวร