<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Integrity on Commentary of Takao</title><link>https://takao.blog/es/tags/integrity/</link><description>Recent content in Integrity on Commentary of Takao</description><generator>Hugo -- gohugo.io</generator><language>es</language><copyright>Commentary of Takao</copyright><lastBuildDate>Sun, 12 Jul 2026 04:12:51 +0900</lastBuildDate><atom:link href="https://takao.blog/es/tags/integrity/index.xml" rel="self" type="application/rss+xml"/><item><title>Subresource Integrity (SRI): Garantizando integridad de recursos</title><link>https://takao.blog/es/web/subresource-integrity/</link><pubDate>Fri, 20 Dec 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/subresource-integrity/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/subresource-integrity-es.png" alt="Featured image of post Subresource Integrity (SRI): Garantizando integridad de recursos" /&gt;&lt;p&gt;Subresource Integrity (SRI) permite verificar que un archivo cargado desde un CDN no ha sido manipulado, comparando su hash criptográfico.&lt;/p&gt;
&lt;h2 id="cómo-funciona"&gt;Cómo funciona
&lt;/h2&gt;&lt;p&gt;El atributo &lt;code&gt;integrity&lt;/code&gt; contiene un hash (SHA-256, SHA-384, SHA-512) del contenido esperado. El navegador calcula el hash y lo compara. Si no coincide, bloquea el recurso.&lt;/p&gt;
&lt;h2 id="ejemplo"&gt;Ejemplo
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;script&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;src&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;https://cdn.example.com/lib.js&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;integrity&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;sha384-...&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;crossorigin&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;anonymous&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;El crossorigin es obligatorio para recursos CORS.&lt;/p&gt;
&lt;h2 id="generación-de-hashes"&gt;Generación de hashes
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;openssl dgst -sha384 -binary archivo.js | openssl base64 -A&lt;/code&gt;. O usando herramientas online de SRI. Automatiza en el build process.&lt;/p&gt;</description></item></channel></rss>